package com.fjh.dao.impl;

import com.fjh.domain.User;
import org.apache.ibatis.annotations.Select;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Repository
@Component
@Scope("singleton")
public interface UserDao {
    //查询所有
    @Select("SELECT * FROM user")
    User selectAll();

    //根据id查询
    @Select("SELECT * FROM user WHERE id = #{id}")
    User selectById(int id);

    //根据id删除
    @Select("DELETE FROM user WHERE id = #{id}")
    int deleteById(int id);

    //添加
    @Select("INSERT INTO user(username,password) VALUES(#{username},#{password})")
    int insert(User user);
    @Select("SELECT COUNT(*)  FROM user ")
    int selectCount();
}
